/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DigiRobo;

import java.awt.Point;
import java.awt.Rectangle;

/**
 *
 * @author v034150
 */
public class CoordinateSystem {
    private Point _source;
    
    public CoordinateSystem() {
        _source = new Point(0,0);
    }
    
    public void setSource(Point source) {
        _source = source;
    }
    
    public Rectangle fromUserspace(Rectangle r) {
        Rectangle r1 = new Rectangle(r);
        Point p1 = fromUserspace(new Point(r1.x,r1.y));
        r1.x = p1.x;
        r1.y = p1.y;
        return r1;
    }
    
    public Point toUserspace(Point p1) {
        Point p = new Point();
        p.x = p1.x + _source.x;
        p.y = _source.y - p1.y;
        return p;
    }

    public Point fromUserspace(Point p) {
        Point p1 = new Point();
        p1.x = p.x - _source.x;
        p1.y = _source.y - p.y;
        return p1;
    }

}
